<form class="layui-form layui-card layui-form-pane" action="{:request()->url()}" data-auto="true" method="post"
    autocomplete="off" style="padding: 10px;">
        <blockquote class="layui-elem-quote" style="text-align: center;">基本参数</blockquote>
        <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
            <div class="layui-form-item" pane>
                <label class="layui-form-label label-required">仓库</label>
                <div class="layui-input-block">
                    <select name='ware_house_id' class='layui-select' lay-search lay-filter="ware_house_id">
                        <!--{foreach $ware_house as $k=>$v}-->
                        <!--{eq name='v.id' value='$vo.ware_house_id|default=0'}-->
                        <option selected value='{$v.id}' data-time_eff='{$v.time_eff}' data-car_eff='{$v.car_eff}'
                            data-hours='{$v.hours}' data-unit_price='{$v.unit_price}'
                            data-income_tuan_price='{$v.income_tuan_price}' data-so_pure_price='{$v.so_pure_price}'
                            data-so_frozen_price='{$v.so_frozen_price}' data-so_big_price='{$v.so_big_price}'
                            data-so_handyman_price='{$v.so_handyman_price}' data-ca_have_price='{$v.ca_have_price}'
                            data-ca_no_price='{$v.ca_no_price}' data-floor_end_at='{$v.floor_end_at}'
                            data-floor_count='{$v.floor_count}'>
                            {$v.name}
                        </option>
                        <!--{else}-->
                        <option value='{$v.id}' data-time_eff='{$v.time_eff}' data-car_eff='{$v.car_eff}'
                            data-hours='{$v.hours}' data-unit_price='{$v.unit_price}'
                            data-income_tuan_price='{$v.income_tuan_price}' data-so_pure_price='{$v.so_pure_price}'
                            data-so_frozen_price='{$v.so_frozen_price}' data-so_big_price='{$v.so_big_price}'
                            data-so_handyman_price='{$v.so_handyman_price}' data-ca_have_price='{$v.ca_have_price}'
                            data-ca_no_price='{$v.ca_no_price}'>
                            {$v.name}</option>
                        <!--{/eq}-->
                        <!--{/foreach}-->
                    </select>
                </div>
            </div>
        </div>
        
        <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="layui-form-item" pane>
                <label class="layui-form-label">每日预估件数</label>
                <div class="layui-input-block">
                    <input name="quantity" value='{$vo.quantity|default=""}' required placeholder="请输入预估量"
                        class="layui-input" type="number" oninput="myFunction()">
                </div>
            </div>
        </div>
        <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="layui-form-item" pane>
                <label class="layui-form-label">预估团点数</label>
                <div class="layui-input-block">
                    <input name="tuan_point" value='{$vo.tuan_point|default=""}' required placeholder="请输入预估团点数"
                        class="layui-input" type="number" oninput="myFunction()">
                </div>
            </div>
        </div>
        <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="layui-form-item  " pane>
                <label class="layui-form-label">履约日期</label>
                <div class="layui-input-block">
                    <input data-date-input="date" name="plan_date" value='{$vo.plan_date|default=""}' required
                        placeholder="请输入履约日期" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="layui-form-item  " pane>
                <label class="layui-form-label car_number">计划车辆</label>
                <div class="layui-input-block">
                    <input name="car_number" value='{$vo.car_number|default=""}' readonly placeholder="计划车辆"
                        class="layui-input layui-bg-gray" type="number">

                </div>

            </div>
            <p class="color-desc">每日预估件数/标准车效</p>
        </div>
        <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="layui-form-item  " pane>
                <label class="layui-form-label man_number">计划分拣人数</label>
                <div class="layui-input-block">
                    <input name="man_number" value='{$vo.man_number|default=""}' readonly placeholder="计划分拣人数"
                        class="layui-input layui-bg-gray" type="number">

                </div>
            </div>
            <p class="color-desc">每日预估件数/工作小时数/标准时效</p>
        </div>


        {if auth("look_income")}
        <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="layui-form-item  " pane>
                <label class="layui-form-label">基础收入</label>
                <div class="layui-input-block">
                    <input name="income" value='{$vo.income|default=""}' readonly placeholder="基础收入"
                        class="layui-input layui-bg-gray">

                </div>
            </div>
            <p class="color-desc">履约日期<=保底截止日期 <br>基础单价*保底数量+团点单价*预估团点数保底数量</p>
            <p class="color-desc">履约日期>保底截止日期 <br>基础单价*预估件数+团点单价*预估团点数</p>
        </div>
        {/if}
    

    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
        <div class="layui-form-item  " pane>
            <label class="layui-form-label">当日运力成本</label>
            <div class="layui-input-block">
                <input name="ca_cost" readonly value='{$vo.ca_cost|default=""}' placeholder="运力成本"
                    class="layui-input layui-bg-gray">
            </div>
        </div>

    </div>
    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
        <div class="layui-form-item  " pane>
            <label class="layui-form-label">当日分拣成本</label>
            <div class="layui-input-block">
                <input name="so_cost" readonly value='{$vo.so_cost|default=""}' placeholder="当日分拣成本"
                    class="layui-input layui-bg-gray">
            </div>
        </div>

    </div>
    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
        <div class="layui-form-item  " pane>
            <label class="layui-form-label">总成本</label>
            <div class="layui-input-block">
                <input name="cost" readonly value='{$vo.cost|default=""}' placeholder="总成本"
                    class="layui-input layui-bg-gray">
            </div>
        </div>
    </div>
    <div class="layui-form-item"></div>
    <blockquote class="layui-elem-quote" style="text-align: center;">明细参数</blockquote>
    <label class="color-green font-w7 label-required">运力需求明细<span class="label-required" required></span></label>
    <div style="text-align: center;">
        <table class="layui-table">
            <colgroup>
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="200">
                <col>
            </colgroup>
            <thead>
                <tr>
                    <th class="text-center label-required">岗位</th>
                    <th class="text-center label-required">属性</th>
                    <th class="text-center label-required">结算方式</th>
                    <th class="text-center label-required">车辆数</th>
                    <th class="text-center">是否含税</th>
                    <th class="text-center">单价</th>
                    <th></th>
                </tr>
            </thead>
            <tbody class="ca_fixed_content">
                {notempty name='vo.ca_fixed'}
                {foreach $vo.ca_fixed as $k=>$v}
                <tr>
                    <td>
                        <select name='ca_fixed[jobs][]' class='layui-select jobs' lay-search lay-filter="jobs">
                            <!--{foreach [0=>'有车',1=>'无车'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.jobs|default=0'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <select name='ca_fixed[att][]' class='layui-select' lay-search>
                            <!--{foreach [0=>'车队',1=>'个人'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.att|default=0'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <select name='ca_fixed[payment_way][]' class='layui-select' lay-search>
                            <!--{foreach [0=>'周结',1=>'月结'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.payment_way|default=1'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <input name="ca_fixed[count][]" required value='{$v.count|default=""}' class="layui-input"
                            type="number" oninput="price_change()">
                    </td>
                    <td>
                        <select name='ca_fixed[is_rate][]' class='layui-select' lay-search>
                            <!--{foreach [0=>'否',1=>'是'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.is_rate|default=0'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <input name="ca_fixed[price][]" value='{$v.price|default=""}'
                            class="layui-input layui-bg-gray price" readonly>
                    </td>
                    <td>
                        <a href="javascript:void(0);" class="layui-btn layui-btn-danger" onclick="del(this)">删除</a>
                    </td>
                </tr>
                {/foreach}
                {/notempty}
            </tbody>
        </table>
        <button type="button" class="layui-btn layui-btn-normal" onclick="add_ca_fixed()">新增</button>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">运力明细成本</label>
        <div class="layui-input-block">
            <input name="ca_fixed_cost" readonly value='{$vo.ca_fixed_cost|default=""}' placeholder="固定运力成本"
                class="layui-input layui-bg-gray">
        </div>
    </div>
    <label class="color-green font-w7">运力需求新增</label>
    <div style="text-align: center;">
        <table class="layui-table">
            <colgroup>
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="200">
                <col width="200">
                <col>
            </colgroup>
            <thead>
                <tr>
                    <th class="text-center label-required">岗位</th>
                    <th class="text-center label-required">属性</th>
                    <th class="text-center label-required">结算方式</th>
                    <th class="text-center label-required">车辆数</th>
                    <th class="text-center">是否含税</th>
                    <th class="text-center">单价</th>
                    <th class="text-center label-required">原因</th>
                    <th></th>
                </tr>
            </thead>
            <tbody class="ca_temporary_content">
                {notempty name='vo.ca_temporary'}
                {foreach $vo.ca_temporary as $k=>$v}
                <tr>
                    <td>
                        <select name='ca_temporary[jobs][]' class='layui-select jobs' lay-search lay-filter="jobs">
                            <!--{foreach [0=>'有车',1=>'无车'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.jobs|default=0'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <select name='ca_temporary[att][]' class='layui-select' lay-search>
                            <!--{foreach [0=>'车队',1=>'个人'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.att|default=0'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <select name='ca_temporary[payment_way][]' class='layui-select' lay-search>
                            <!--{foreach [0=>'周结',1=>'月结'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.payment_way|default=1'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <input name="ca_temporary[count][]" value='{$v.count|default=""}' class="layui-input"
                            type="number" oninput="price_change()" required>
                    </td>
                    <td>
                        <select name='ca_temporary[is_rate][]' class='layui-select' lay-search>
                            <!--{foreach [0=>'否',1=>'是'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.is_rate|default=0'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <input name="ca_temporary[price][]" value='{$v.price|default=""}'
                            class="layui-input layui-bg-gray price" readonly>
                    </td>
                    <td>
                        <textarea name="ca_temporary[reason][]" class="layui-textarea"
                            required>{$v.reason|default=""}</textarea>
                    </td>
                    <td><a href="javascript:void(0);" class="layui-btn layui-btn-danger" onclick="del(this)">删除</a></td>
                </tr>
                {/foreach}
                {/notempty}
            </tbody>
        </table>
        <button type="button" class="layui-btn layui-btn-normal" onclick="add_ca_temporary()">新增</button>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">运力新增成本</label>
        <div class="layui-input-block">
            <input name="ca_temporary_cost" readonly value='{$vo.ca_temporary_cost|default=""}' placeholder="临时运力需求成本"
                class="layui-input layui-bg-gray">
        </div>
    </div>
    <label class="color-green font-w7 ">分拣需求明细 <span class="label-required" required></span></label>
    <div style="text-align: center;">
        <table class="layui-table">
            <colgroup>
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="200">
                <col>
            </colgroup>
            <thead>
                <tr>
                    <th class="text-center label-required">岗位</th>
                    <th class="text-center label-required">属性</th>
                    <th class="text-center label-required">结算方式</th>
                    <th class="text-center label-required">人数</th>
                    <th class="text-center">是否含税</th>
                    <th class="text-center">单价</th>
                    <th></th>
                </tr>
            </thead>
            <tbody class="so_fixed_content">
                {notempty name='vo.so_fixed'}
                {foreach $vo.so_fixed as $k=>$v}
                <tr>
                    <td>
                        <select name='so_fixed[jobs][]' class='layui-select jobs' lay-search lay-filter="jobs">
                            <!--{foreach [2=>'标品',3=>'冻品',4=>'大件',5=>'杂工'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.jobs|default=2'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <select name='so_fixed[att][]' class='layui-select' lay-search>
                            <!--{foreach [2=>'劳务',3=>'自招',] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.att|default=2'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <select name='so_fixed[payment_way][]' class='layui-select' lay-search>
                            <!--{foreach [0=>'周结',1=>'月结'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.payment_way|default=1'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <input name="so_fixed[count][]" value='{$v.count|default=""}' class="layui-input" type="number"
                            oninput="price_change()" required>
                    </td>
                    <td>
                        <select name='so_fixed[is_rate][]' class='layui-select' lay-search>
                            <!--{foreach [0=>'否',1=>'是'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.is_rate|default=0'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <input name="so_fixed[price][]" value='{$v.price|default=""}'
                            class="layui-input layui-bg-gray price" readonly>
                    </td>
                    <td>
                        <a href="javascript:void(0);" class="layui-btn layui-btn-danger" onclick="del(this)">删除</a>
                    </td>
                </tr>
                {/foreach}
                {/notempty}
            </tbody>
        </table>
        <button type="button" class="layui-btn layui-btn-normal" onclick="add_so_fixed()">新增</button>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">分拣明细成本</label>
        <div class="layui-input-block">
            <input name="so_fixed_cost" readonly value='{$vo.so_fixed_cost|default=""}' placeholder="固定分拣成本"
                class="layui-input layui-bg-gray">
        </div>
    </div>
    <label class="color-green font-w7">分拣需求新增</label>
    <div style="text-align: center;">
        <table class="layui-table">
            <colgroup>
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="150">
                <col width="200">
                <col width="200">
                <col>
            </colgroup>
            <thead>
                <tr>
                    <th class="text-center label-required">岗位</th>
                    <th class="text-center label-required">属性</th>
                    <th class="text-center label-required">结算方式</th>
                    <th class="text-center label-required">人数</th>
                    <th class="text-center">是否含税</th>
                    <th class="text-center">单价</th>
                    <th class="text-center label-required">原因</th>
                    <th></th>
                </tr>
            </thead>
            <tbody class="so_temporary_content">
                {notempty name='vo.so_temporary'}
                {foreach $vo.so_temporary as $k=>$v}
                <tr>
                    <td>
                        <select name='so_temporary[jobs][]' class='layui-select jobs' lay-search lay-filter="jobs">
                            <!--{foreach [2=>'标品',3=>'冻品',4=>'大件',5=>'杂工'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.jobs|default=2'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <select name='so_temporary[att][]' class='layui-select' lay-search>
                            <!--{foreach [2=>'劳务',3=>'自招',] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.att|default=2'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <select name='so_temporary[payment_way][]' class='layui-select' lay-search>
                            <!--{foreach [0=>'周结',1=>'月结'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.payment_way|default=1'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <input name="so_temporary[count][]" value='{$v.count|default=""}' class="layui-input"
                            type="number" oninput="price_change()" required>
                    </td>
                    <td>
                        <select name='so_temporary[is_rate][]' class='layui-select' lay-search>
                            <!--{foreach [0=>'否',1=>'是'] as $kk=>$vv}-->
                            <!--{eq name='kk' value='$v.is_rate|default=0'}-->
                            <option selected value='{$kk}'>{$vv}</option>
                            <!--{else}-->
                            <option value='{$kk}'>{$vv}</option>
                            <!--{/eq}-->
                            <!--{/foreach}-->
                        </select>
                    </td>
                    <td>
                        <input name="so_temporary[price][]" value='{$v.price|default=""}'
                            class="layui-input layui-bg-gray price" readonly>
                    </td>
                    <td>
                        <textarea name="so_temporary[reason][]" required
                            class="layui-textarea">{$v.reason|default=""}</textarea>
                    </td>
                    <td>
                        <a href="javascript:void(0);" class="layui-btn layui-btn-danger" onclick="del(this)">删除</a>
                    </td>
                </tr>
                {/foreach}
                {/notempty}
            </tbody>
        </table>
        <button type="button" class="layui-btn layui-btn-normal" onclick="add_so_temporary()">新增</button>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">分拣新增成本</label>
        <div class="layui-input-block">
            <input name="so_temporary_cost" readonly value='{$vo.so_temporary_cost|default=""}' placeholder="临时分拣成本"
                class="layui-input layui-bg-gray">
        </div>
    </div>
    <blockquote class="layui-elem-quote" style="text-align: center;">资源盘点</blockquote>


    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
        <div class="layui-form-item  " pane>
            <label class="layui-form-label">已有车辆(台)</label>
            <div class="layui-input-block">
                <input name="have_car" value='{$vo.have_car|default=""}' placeholder="请输入已有车辆" class="layui-input"
                    type="number">
            </div>
        </div>

    </div>
    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
        <div class="layui-form-item  " pane>
            <label class="layui-form-label">车辆缺口(台)</label>
            <div class="layui-input-block">
                <input name="lack_car" value='{$vo.lack_car|default=""}' placeholder="请输入车辆缺少" class="layui-input"
                    type="number">
            </div>
        </div>

    </div>
    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
        <div class="layui-form-item  " pane>
            <label class="layui-form-label">解决方式</label>
            <div class="layui-input-block">
                <select name='car_way' class='layui-select' lay-search>
                    <!--{foreach [0=>'站内解决',1=>'总部统筹'] as $k=>$v}-->
                    <!--{eq name='k' value='$vo.car_way|default=0'}-->
                    <option selected value='{$k}'>{$v}</option>
                    <!--{else}-->
                    <option value='{$k}'>{$v}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </div>
        </div>

    </div>

    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
        <div class="layui-form-item  " pane>
            <label class="layui-form-label">已有分拣(人)</label>
            <div class="layui-input-block">
                <input name="have_man" value='{$vo.have_man|default=""}' placeholder="请输入已有分拣" class="layui-input"
                    type="number">
            </div>
        </div>

    </div>
    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
        <div class="layui-form-item" pane>
            <label class="layui-form-label">分拣缺口(人)</label>
            <div class="layui-input-block">
                <input name="lack_man" value='{$vo.lack_man|default=""}' placeholder="请输入分拣缺少" class="layui-input"
                    type="number">
            </div>
        </div>

    </div>
    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
        <div class="layui-form-item" pane>
            <label class="layui-form-label">解决方式</label>
            <div class="layui-input-block">
                <select name='man_way' class='layui-select' lay-search>
                    <!--{foreach [0=>'站内解决',1=>'总部统筹'] as $k=>$v}-->
                    <!--{eq name='k' value='$vo.man_way|default=0'}-->
                    <option selected value='{$k}'>{$v}</option>
                    <!--{else}-->
                    <option value='{$k}'>{$v}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </div>
        </div>
    </div>

    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>

    <script>
        window.form.render();
        $(function () {

        })

        //仓库选择实时变化事件
        form.on('select(ware_house_id)', function (data) {
            myFunction();
            price_change();
        });

        //每日预估件数和预估团点数输入实时变化事件
        function myFunction() {
            var quantity = Number($("input[name='quantity']").val());
            var tuan_point = Number($("input[name='tuan_point']").val());
            var time_eff = Number($("select[name='ware_house_id']").find("option:selected").data('time_eff'));
            var car_eff = Number($("select[name='ware_house_id']").find("option:selected").data('car_eff'));
            var hours = Number($("select[name='ware_house_id']").find("option:selected").data('hours'));
            var unit_price = Number($("select[name='ware_house_id']").find("option:selected").data('unit_price'));
            var income_tuan_price = Number($("select[name='ware_house_id']").find("option:selected").data('income_tuan_price'));
            var floor_count = Number($("select[name='ware_house_id']").find("option:selected").data('floor_count'));
            var floor_end_at = $("select[name='ware_house_id']").find("option:selected").data('floor_end_at');
            var plan_date = $('input[name="plan_date"]').val();
            $("input[name='car_number']").val(Math.ceil(quantity / car_eff));
            $("input[name='man_number']").val(Math.ceil(quantity / hours / time_eff));
            if (plan_date <= floor_end_at) {
                //如果履约日期小于等于保底截止日期 基础收入=基础单价*保底数量+团点单价*预估团点数保底数量
                $("input[name='income']").val((unit_price * floor_count + income_tuan_price * tuan_point).toFixed(2));
            } else {
                //如果履约日期大于保底截止日期 基础收入=基础单价*预估件数+团点单价*预估团点数
                $("input[name='income']").val((unit_price * quantity + income_tuan_price * tuan_point).toFixed(2));
            }
        }

        //修改岗位
        form.on('select(jobs)', function (data) {
            price_change();
        });

        //运力需求明细
        $ca_fixed_html = `
        <tr>
            <td>
                <select name='ca_fixed[jobs][]' class='layui-select jobs' lay-search lay-filter="jobs">
                    <!--{foreach [0=>'有车',1=>'无车'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='0'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <select name='ca_fixed[att][]' class='layui-select' lay-search>
                    <!--{foreach [0=>'车队',1=>'个人'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='0'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <select name='ca_fixed[payment_way][]' class='layui-select' lay-search>
                    <!--{foreach [0=>'周结',1=>'月结'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='1'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <input name="ca_fixed[count][]" required
                    class="layui-input" type="number" oninput="price_change()">
            </td>
            <td>
                <select name='ca_fixed[is_rate][]' class='layui-select' lay-search>
                    <!--{foreach [0=>'否',1=>'是'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='0'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <input name="ca_fixed[price][]"
                    class="layui-input layui-bg-gray price" readonly>
            </td>
            <td>
                <a href="javascript:void(0);" class="layui-btn layui-btn-danger"
                    onclick="del(this)">删除</a>
            </td>
        </tr>
        `;
        function add_ca_fixed() {
            //追加子元素
            $('.ca_fixed_content').append($ca_fixed_html);
            price_change();
            layui.form.render()
        }


        //运力需求新增
        $ca_temporary_html = `
        <tr>
            <td>
                <select name='ca_temporary[jobs][]' class='layui-select jobs' lay-search lay-filter="jobs">
                    <!--{foreach [0=>'有车',1=>'无车'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='0'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <select name='ca_temporary[att][]' class='layui-select' lay-search>
                    <!--{foreach [0=>'车队',1=>'个人'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='0'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <select name='ca_temporary[payment_way][]' class='layui-select' lay-search>
                    <!--{foreach [0=>'周结',1=>'月结'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='1'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <input name="ca_temporary[count][]" class="layui-input" type="number" oninput="price_change()" required>
            </td>
            <td>
                <select name='ca_temporary[is_rate][]' class='layui-select' lay-search>
                    <!--{foreach [0=>'否',1=>'是'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='0'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                
                <input name="ca_temporary[price][]" 
                    class="layui-input layui-bg-gray price" readonly>
            </td>
            <td>
                <textarea name="ca_temporary[reason][]" class="layui-textarea" required></textarea>
            </td>
            <td><a href="javascript:void(0);" class="layui-btn layui-btn-danger"
                    onclick="del(this)">删除</a></td>
        </tr>
        `;
        function add_ca_temporary() {
            //追加子元素
            $('.ca_temporary_content').append($ca_temporary_html);
            price_change();
            layui.form.render()
        }

        //分拣需求明细
        $so_fixed_html = `
        <tr>
            <td>
                <select name='so_fixed[jobs][]' class='layui-select jobs' lay-search lay-filter="jobs">
                    <!--{foreach [2=>'标品',3=>'冻品',4=>'大件',5=>'杂工'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='2'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <select name='so_fixed[att][]' class='layui-select' lay-search>
                    <!--{foreach [2=>'劳务',3=>'自招',] as $kk=>$vv}-->
                    <!--{eq name='kk' value='2'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <select name='so_fixed[payment_way][]' class='layui-select' lay-search>
                    <!--{foreach [0=>'周结',1=>'月结'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='1'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <input name="so_fixed[count][]" class="layui-input" required
                    type="number" oninput="price_change()">
            </td>
            <td>
                <select name='so_fixed[is_rate][]' class='layui-select' lay-search>
                    <!--{foreach [0=>'否',1=>'是'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='0'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <input name="so_fixed[price][]" class="layui-input layui-bg-gray price"
                    readonly>
            </td>
            <td>
                <a href="javascript:void(0);" class="layui-btn layui-btn-danger"
                    onclick="del(this)">删除</a>
            </td>
        </tr>
        `;
        function add_so_fixed() {
            //追加子元素
            $('.so_fixed_content').append($so_fixed_html);
            price_change();
            layui.form.render()
        }

        //分拣需求新增
        $so_temporary_html = `
        <tr>
            <td>
                <select name='so_temporary[jobs][]' class='layui-select jobs' lay-search lay-filter="jobs">
                    <!--{foreach [2=>'标品',3=>'冻品',4=>'大件',5=>'杂工'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='2'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <select name='so_temporary[att][]' class='layui-select' lay-search>
                    <!--{foreach [2=>'劳务',3=>'自招',] as $kk=>$vv}-->
                    <!--{eq name='kk' value='2'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <select name='so_temporary[payment_way][]' class='layui-select' lay-search>
                    <!--{foreach [0=>'周结',1=>'月结'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='1'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <input name="so_temporary[count][]" class="layui-input" required
                    type="number" oninput="price_change()">
            </td>
            <td>
                <select name='so_temporary[is_rate][]' class='layui-select' lay-search>
                    <!--{foreach [0=>'否',1=>'是'] as $kk=>$vv}-->
                    <!--{eq name='kk' value='0'}-->
                    <option selected value='{$kk}'>{$vv}</option>
                    <!--{else}-->
                    <option value='{$kk}'>{$vv}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </td>
            <td>
                <input name="so_temporary[price][]" class="layui-input layui-bg-gray price"
                    readonly>
            </td>
            <td>
                <textarea name="so_temporary[reason][]" required
                    class="layui-textarea"></textarea>
            </td>
            <td>
                <a href="javascript:void(0);" class="layui-btn layui-btn-danger"
                    onclick="del(this)">删除</a>
            </td>
        </tr>
        `;
        function add_so_temporary() {
            //追加子元素
            $('.so_temporary_content').append($so_temporary_html);
            price_change();
            layui.form.render()
        }

        function del(that) {
            $(that).parent().parent().remove();
            price_change();
        }

        function price_change() {
            //渲染单价
            $('.jobs').each(function () {
                var so_pure_price = $('select[name="ware_house_id"] option:selected').data('so_pure_price');
                var so_frozen_price = $('select[name="ware_house_id"] option:selected').data('so_frozen_price');
                var so_big_price = $('select[name="ware_house_id"] option:selected').data('so_big_price');
                var so_handyman_price = $('select[name="ware_house_id"] option:selected').data('so_handyman_price');
                var ca_have_price = $('select[name="ware_house_id"] option:selected').data('ca_have_price');
                var ca_no_price = $('select[name="ware_house_id"] option:selected').data('ca_no_price');
                var jobs = $(this).val();
                // var jobs = $(this).parent().parent().find('select[name="ca_fixed[jobs][]"] option:selected').val();
                //岗位 0有车 1无车 2标品 3冻品 4大件 5杂工
                if (jobs == 0) {
                    $(this).parent().parent().find('.price').val(ca_have_price);
                } else if (jobs == 1) {
                    $(this).parent().parent().find('.price').val(ca_no_price);
                } else if (jobs == 2) {
                    $(this).parent().parent().find('.price').val(so_pure_price);
                } else if (jobs == 3) {
                    $(this).parent().parent().find('.price').val(so_frozen_price);
                } else if (jobs == 4) {
                    $(this).parent().parent().find('.price').val(so_big_price);
                } else if (jobs == 5) {
                    $(this).parent().parent().find('.price').val(so_handyman_price);
                }
            });
            //计算运力明细成本
            var ca_fixed_cost = 0;
            $('input[name="ca_fixed[price][]"]').each(function () {
                ca_fixed_cost += $(this).val() * $(this).parent().parent().find('input[name="ca_fixed[count][]"]').val();
            })
            $('input[name="ca_fixed_cost"]').val(ca_fixed_cost.toFixed(2));
            //计算运力新增成本
            var ca_temporary_cost = 0;
            $('input[name="ca_temporary[price][]"]').each(function () {
                ca_temporary_cost += $(this).val() * $(this).parent().parent().find('input[name="ca_temporary[count][]"]').val();
            })
            $('input[name="ca_temporary_cost"]').val(ca_temporary_cost.toFixed(2));
            //计算分拣明细成本
            var so_fixed_cost = 0;
            $('input[name="so_fixed[price][]"]').each(function () {
                so_fixed_cost += $(this).val() * $(this).parent().parent().find('input[name="so_fixed[count][]"]').val();
            })
            $('input[name="so_fixed_cost"]').val(so_fixed_cost.toFixed(2));
            //计算分拣新增成本
            var so_temporary_cost = 0;
            $('input[name="so_temporary[price][]"]').each(function () {
                so_temporary_cost += $(this).val() * $(this).parent().parent().find('input[name="so_temporary[count][]"]').val();
            })
            $('input[name="so_temporary_cost"]').val(so_temporary_cost.toFixed(2));
            //当日运力成本
            $('input[name="ca_cost"]').val((ca_fixed_cost + ca_temporary_cost).toFixed(2));
            //当日分拣成本
            $('input[name="so_cost"]').val((so_fixed_cost + so_temporary_cost).toFixed(2));
            //总成本
            $('input[name="cost"]').val((ca_fixed_cost + ca_temporary_cost + so_fixed_cost + so_temporary_cost).toFixed(2));
        }
    </script>

</form>